package yf.mall.controller;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yf.annotation.SysLog;

import java.util.Map;

import com.yf.consts.DaoConst;
import yf.mall.entity.PointSignEntity;
import yf.mall.service.PointSignService;
import com.yf.response.R;


/**
 * 积分签到Controller
 *
 * @author hxf
 * @email 505860922@qq.com
 * @date Tue Nov 12 16:21:48 CST 2019
 */
@RestController
@RequestMapping("/point/sign")
public class PointSignController {
    @Autowired
    private PointSignService pointSignService;

    /**
     * 列表积分签到
     */
    @RequestMapping("/list")
    @RequiresPermissions("point:sign:list")
    public R list(@RequestParam Map<String, Object> params) {
        PageHelper.startPage(DaoConst.getPage(params), DaoConst.getLIMIT(params));
        List<PointSignEntity> pointSignList = pointSignService.queryList(params);
        return R.ok(new PageInfo(pointSignList));
    }

    /**
     * 查看积分签到
     */
    @SysLog("查看积分签到")
    @RequestMapping("/info/{id}")
    @RequiresPermissions("point:sign:info")
    public R info(@PathVariable("id") Long id) {
        PointSignEntity pointSign = pointSignService.get(id);

        return R.ok(pointSign);
    }

    /**
     * 保存积分签到
     */
    @SysLog("保存积分签到")
    @RequestMapping("/save")
    @RequiresPermissions("point:sign:save")
    public R save(PointSignEntity pointSign) {
        pointSignService.save(pointSign);

        return R.ok(pointSign);
    }

    /**
     * 修改积分签到
     */
    @SysLog("修改积分签到")
    @RequestMapping("/update")
    @RequiresPermissions("point:sign:update")
    public R update(PointSignEntity pointSign) {
        pointSignService.update(pointSign);

        return R.ok(pointSign);
    }

    /**
     * 删除积分签到
     */
    @SysLog("删除积分签到")
    @RequestMapping("/delete")
    @RequiresPermissions("point:sign:delete")
    public R delete(Long[] ids) {
        pointSignService.deleteBatch(ids);

        return R.ok();
    }

    /**
     * 所有积分签到
     */
    @SysLog("所有积分签到")
    @RequestMapping("/queryAll")
    public R queryAll(@RequestParam Map<String, Object> params) {

        List<PointSignEntity> pointSignList = pointSignService.queryList(params);

        return R.ok(pointSignList);
    }

    /**
     @ModelAttribute public SearchParam<PointSignEntity> searchParam(SearchParam<PointSignEntity> params, PointSignEntity pointSign) {
     if (pointSign != null) {
     params.setEntity(pointSign);
     }

     return params;
     }
     **/
    /***********自定义开始***********/
}
